import React from 'react'
import {plusAction,minusAction} from './redux/actions'
import { connect } from 'react-redux'

class Count extends React.Component{
    constructor(props){
        super(props)
    }
    render(){
        return(
            <div>
                <button onClick={()=>{
                    this.props.minus()
                }}>-</button>
                <p>{this.props.count}</p>
                <button onClick={()=>{
                    this.props.plus()
                }}>+</button>
            </div>
        )
    }
} 
    function forAction(dispatch){
        return{
          plus:()=>{dispatch(plusAction())},
          minus:()=>{dispatch(minusAction())}
        }
      }
    function forState(rootReducer){
        return{
          count:rootReducer.counterReducer.count
        }
    }
export default connect(forState,forAction)(Count)

